

<?php
//Name: Admin.php
//Purpose: This script is for administrators to view all users 
//CreateDate: 10/01/12
//check if user is admin, create session var to declare if is admin
session_name('login');
session_start();
if($_SESSION['isAdmin'] == false)
{
	header("location: /home.php");
	exit;
}

//to seperate each line in to an array entry
$usersArray = file("users.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

//to seperate each user in to an array
foreach ($usersArray as &$user)
{
	$user = explode("|", $user);
}

$numberOfUsers = count($usersArray);



//display all all users info

//dispaly total users

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
	<head>
		<script src="javascript/tcaparrel.js" type="text/javascript"></script>
		<link rel="StyleSheet" href="css/tcaparrel.css" type="text/css">
		<link rel="StyleSheet" href="css/header.css" type="text/css">
	</head>

	<body class="productPage">
	<div class="contentWrapper">
		<div class="header">
		<?php 
		session_name('login');
		session_start();
		if(isset($_SESSION['username']))
		{
			include('loggedInUserHeader.php');
		}
		else
		{
			include ('loginformheader.php');
		}
		?>
		</div>
		
		<div class="menubarContentWrapper">
			<div class="menubar">
				<div class="menuItem" onclick="sweatshirts_click()"><label style="cursor: inherit">SweatShirts</label></div>
				<div class="menuItem" onclick="hats_click()"><label style="cursor: inherit">Hats</label></div>
				<div class="menuItem" onclick="tshirts_click()"><label style="cursor: inherit">T-Shirts</label></div>
				<div class="menuItem" onclick="pants_click()"><label style="cursor: inherit">Pants</label></div>
			</div>
		</div>
		
		<div class="adminContainer">
			<div class="allUsers">
				Total Number of Users: <?php echo $numberOfUsers; ?>
			</div>
				<table class="allUsers">
					<tr>
						<th>Username</th>
						<th>Password</th>
						<th>Frist Name</th>
						<th>Last Name</th>
						<th>DOB</th>
						<th>Gender</th>
						<th>Email</th>
					</tr>
				<?php 
				
					foreach($usersArray as &$user)
					{
						echo '
					<tr>
						<td class="allUsers">'.$user[0].'</td>
						<td class="allUsers">'.$user[1].'</td>
						<td class="allUsers">'.$user[2].'</td>
						<td class="allUsers">'.$user[3].'</td>
						<td class="allUsers">'.$user[4].'</td>
						<td class="allUsers">'.$user[5].'</td>
						<td class="allUsers">'.$user[6].'</td>
					</tr>
							';
					}
				?>
				</table>
		</div>
		
		<div class="footer"></div>
		</div>
	</body>

</html>